package com.da.landlord;

import java.io.File;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;






import com.googlecode.cswish.annotation.cm;
import com.ra.landlord.BankCard;
import com.ra.landlord.LandlordOwner;
import com.ra.landlord.LandlordOwnerUser;

/**
 * 业主
 * @author Peter.Z
 *
 */
@Entity
@Table(name="da_daowner")
public class DaOwner implements LandlordOwner {
	
	private Integer id;
	
	@cm("房东")
	private LandlordOwnerUser landlordUser;
	
	@cm("姓名")
	private String name;
	
	@cm("性别")
	private Integer gender;
	
	@cm("住址描述")
	private String addrDsc;
	
	@cm("手机号1")
	private String phone;
	
	@cm("手机号2")
	private String phoneTwo;

	@cm("qq")
	private String qq;
	
	@cm("邮箱")
	private String email;
	
	@cm("身份证号")
	private String idCard;
	
	@cm("照片")
	private File photo;
	
	@cm("文件类型")
	private String photoContentType;
	
	@cm("文件全名")
	private String photoFileName;
	
	@cm("业主名下所有合约")
	private List<DaOwnerAgreement> ownerAgreement;
	
	@cm("银行卡")
	private List<BankCard> bankCards;
	
	@cm("业主下的所有房源")//保留字段
	private List<DaSuite> suites;
	
	@cm("业主描述")
	private String mark;
	

	@OneToMany(cascade=CascadeType.ALL)
	@JoinTable(name="da_daowner_bankcard", joinColumns=@JoinColumn(name="DaOwner_id"), inverseJoinColumns=@JoinColumn(name="bankCards_id"))
	public List<BankCard> getBankCards() {
		return bankCards;
	}

	public void setBankCards(List<BankCard> bankCards) {
		this.bankCards = bankCards;
	}
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}

	@Transient
	public File getPhoto() {
		return photo;
	}

	public void setPhoto(File photo) {
		this.photo = photo;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	@OneToMany(mappedBy="owner",cascade=CascadeType.ALL)
	public List<DaOwnerAgreement> getOwnerAgreement() {
		return ownerAgreement;
	}

	public void setOwnerAgreement(List<DaOwnerAgreement> ownerAgreement) {
		this.ownerAgreement = ownerAgreement;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public String getAddrDsc() {
		return addrDsc;
	}

	public void setAddrDsc(String addrDsc) {
		this.addrDsc = addrDsc;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPhoneTwo() {
		return phoneTwo;
	}

	public void setPhoneTwo(String phoneTwo) {
		this.phoneTwo = phoneTwo;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Transient
	public String getPhotoContentType() {
		return photoContentType;
	}

	public void setPhotoContentType(String photoContentType) {
		this.photoContentType = photoContentType;
	}

	public String getPhotoFileName() {
		return photoFileName;
	}

	public void setPhotoFileName(String photoFileName) {
		this.photoFileName = photoFileName;
	}
	
	@OneToMany(mappedBy="daOwner",cascade=CascadeType.REFRESH)
	public List<DaSuite> getSuites() {
		return suites;
	}
	

	public void setSuites(List<DaSuite> suites) {
		this.suites = suites;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	@Override
	public void setLandlordUser(LandlordOwnerUser LandlordOwner) {
		this.landlordUser = LandlordOwner;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}
	
	
}
